<%@  page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8" import = "com.exam.paperBean,java.util.*,com.exam.questionBean.*,com.exam.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<style type="text/css">
#apDiv1 {
	position:absolute;
	left:-1px;
	top:212px;
	width:252px;
	height:316px;
	z-index:1;
}
</style>
</head>




<% 	
	paperBean paper = (paperBean)session.getAttribute("paper"); 
	String courseName = (String)request.getAttribute("cName");
	String time = (String)request.getAttribute("time");
	String studentName = (String)request.getAttribute("sName");
	String insName = (String)request.getAttribute("iName");
	
%>
<body>



<div id="apDiv1">
  <p><img src="title.gif" width="191" height="145" /></p>
  <table width="200" border="0" cellspacing="5">
    <tr>
      <th scope="row">考试课程</th>
      <td><%=courseName%></td>
    </tr>
    <tr>
      <th scope="row">考试时间</th>
      <td><%= time %>分钟</td>
    </tr>
    <tr>
      <th scope="row">考生学号</th>
      <td><%=paper.getS_id() %></td>
    </tr>
    <tr>
      <th scope="row">考生姓名</th>
      <td><%= studentName %></td>
    </tr>
    <tr>
      <th scope="row">任课教师</th>
      <td><%= insName %></td>
    </tr>
  </table>
</div>

<script type="text/javascript">
	
	var the_timeout;
	var minute = <%=time%>;
	var second = 0;

	function update(){
		the_timeout = setTimeout("update()",1000);
		//var the_number = window.document.form1.textfield.value;		
		minute = minDecrease(minute,second);
		second = secDecrease(minute,second);
		
		window.document.form1.textfield.value = minFix(minute)+"分"+secFix(second)+"秒";
		
		if(minute==10 && second==0){
			alert("考试还剩余10分钟，请检查答案是否填写正确");
		}
		
		if(minute==0 && second==0){
			document.forms.item(1).submit();	
		}
		
	}
	
	function secDecrease(the_minute,the_second){

		if(the_second > 0){
			the_second = parseInt(the_second) - 1;	
		}else{
			the_second = 60;
		}	
		
		return the_second;
	}
	function minDecrease(the_minute,the_second){
		
		if(the_second == 0){
			the_minute = parseInt(minute)-1;	
		}
		
		return the_minute;
	}
	function minFix(min_fix){
		if(min_fix < 10){
			min_fix = "0" + min_fix;	
		}	
		
		return min_fix;
	}
	
	function secFix(sec_fix){
		if(sec_fix<10){
			sec_fix = "0" + sec_fix;	
		}	
		
		return sec_fix;
	}
</script>



<p><img src="e-exam.gif" width="680" height="170" /></p>
<table width="1003" border="0" cellspacing="1">
  <tr>
    <td width="252"><p>&nbsp;</p></td>
    <td width="744">
    
    <p>&nbsp;</p>
    <p>&nbsp;</p>
      <% 
    	ArrayList<String> cqStringList = new ArrayList<String>();
		ArrayList<String> sqStringList = new ArrayList<String>();
    	
    	cqTranslator cqtranslator = new cqTranslator();//声明两个translator
		sqTranslator sqtranslator = new sqTranslator();
		
		cqtranslator.setCqTranslator(paper.getcQuestions());//将题目输入translator
		sqtranslator.setSqTranslator(paper.getsQuestions());
			
		cqStringList = cqtranslator.getQuestion();//获得相应的字符串
		sqStringList = sqtranslator.getQuestion();
    %>
      <font   face= "黑体 "   style= "font-size:36px "> <%=paper.getExam_name() %> </font><br />
      
      <form id="form1" name="form1" method="get" action="#">
  		<label for="textfield"></label>
  		本次考试还剩下<input type="text" name="textfield" id="textfield" size="8" readonly="readonly"/>
	  </form>
      <br>
      
      <script type="text/javascript">
		update();
	  </script>
      
      <%=paper.getPaper_id() %>
      <br>
    <form name="form2" action="correct" method="get">
      <% 
    	for(int i=0;i<cqStringList.size();i++){
	 		out.println(cqStringList.get(i)+"<br>");
	 		//out.println(paper.getcQuestions().get(i).getAnswer()+"<br>");
	 	}
		for(int i=0;i<sqStringList.size();i++){
	 		out.println(sqStringList.get(i)+"<br>"); 		
	 	}
		out.println("<input type='submit' value='提交试卷' onClick = confirm(\"确认提交？\")>");
    %>
  </form>
    
    
    
    </td>
	
  </tr>
</table>



</body>
</html>